From 25287af31cf7a4f9b64a1e0e32b5ec2f4cb28b77 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 30 Mar 2021 15:10:00 +0200 Subject: [PATCH] treewide: remove ucode module preloading Instead of preloading ucode modules via the cmdline, require the modules as needed. This simplifies test case constructions since mock modules can be injected by modifying the search path. Signed-off-by: Jo-Philipp Wich --- root/usr/sbin/fw4 | 8 ++++---- root/usr/share/firewall4/main.uc | 2 ++ root/usr/share/ucode/fw4.uc | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/root/usr/sbin/fw4 b/root/usr/sbin/fw4 index ac95473..3e7388b 100755 --- a/root/usr/sbin/fw4 +++ b/root/usr/sbin/fw4 @@ -31,13 +31,13 @@ start() { esac ACTION=start \ - ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 + ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 } 1000>$LOCK } print() { ACTION=print \ - ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN + ucode -S -i $MAIN } stop() { @@ -68,12 +68,12 @@ flush() { reload_sets() { ACTION=reload-sets \ - flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 + flock -x $LOCK ucode -S -i $MAIN | nft $VERBOSE -f /proc/self/fd/0 } lookup() { ACTION=$1 OBJECT=$2 DEVICE=$3 \ - flock -x $LOCK ucode -S -m fs -m uci -m ubus -m fw4 -i $MAIN + flock -x $LOCK ucode -S -i $MAIN } while [ -n "$1" ]; do diff --git a/root/usr/share/firewall4/main.uc b/root/usr/share/firewall4/main.uc index d71e876..6012bd1 100644 --- a/root/usr/share/firewall4/main.uc +++ b/root/usr/share/firewall4/main.uc @@ -1,5 +1,7 @@ {% +let fw4 = require("fw4"); + /* Find existing sets. * * Unfortunately, terse mode (-t) is incompatible with JSON output so diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc index 1d98f61..25df7a6 100644 --- a/root/usr/share/ucode/fw4.uc +++ b/root/usr/share/ucode/fw4.uc @@ -1,5 +1,9 @@ {% +let fs = require("fs"); +let uci = require("uci"); +let ubus = require("ubus"); + let STATEFILE = "/var/run/fw4.state"; let PARSE_LIST = 0x01; -- 2.30.2